/*
 * -------------------------------------------------------------------------------
 * @FilePath     : main.c
 * @Description  : application
 * Copyright (c) 2023 by NanoIC, All Rights Reserved. 
 * @Date         : 2023-11-10 00:58:17
 * @LastEditTime : 2023-11-10 19:56:35
 * @Author       : LvH
 * -------------------------------------------------------------------------------
 */
/*-------------------------------------------------------------------------------
* file:     app_main.c
* brief:    application
* copyright Copyright (C) 2020-2022 @ NanoIC
* Date:     2022-08-15
* Version:  V1.00
* Author:   JMH
*-------------------------------------------------------------------------------*/

/* Includes ---------------------------------------------------------------*/
#include <string.h>
#include <csi_drv.h>
#include <iostring.h>
#include "sys_console.h"
#include "app_cfg.h"
#include "app_init.h"
#include "app_uart.h"
#include "app_key.h"0000000000
#include "one_wire_bus_app.h"
#include "app_timer.h"
#include "app_touchpad.h"
#include "app_gsensor.h"
#include "app_sleeptimer.h"
#include "tl_log.h"

/* Private macro-----------------------------------------------------------*/

/* externs function--------------------------------------------------------*/
extern void system_init(void);
extern void board_init(void);

/* externs variablesr------------------------------------------------------*/

/* Private variablesr------------------------------------------------------*/
uint8_t app_stop_wait_flag = 0;
extern uint8_t close_idet;
extern int r_t;
extern int c_t;
/* Private function--------------------------------------------------------*/




/**
 * @brief 事件进程
 */
uint8_t power_delay_flag=0;
void app_background_evt_process(void)
{

    if(global_soc_init_succes_flag)
    {
        //延时初始化
        app_delay_init();
		//上电通知
		app_power_on_notice();//test
		 
		
    #if APP_KEYBOARD_ENABLE
        //键盘扫描进程
       app_key_process();
		
    #endif         

  //  #if APP_TOUCHPAD_ENABLE

//		app_touch_pad_process();

//    #endif
		//uart进程
        app_uart_process();//tset
		
		//升级流程进程
        ota_data_init();
        //低功耗进程
        app_lowpower_process();
      
        //gsensor 进程
        app_gsensor_process();

        //flash log进程
		task_log_notify_test();
        //500ms进程
//        app_sleep_timer_500ms_process();
		
    }
}
    
int main(void)
{    
	
    system_init();//iwdt (true=enable)； init systick(coret)
    board_init();//log io init (true=enable)
    app_init(); 

//	bool flag = true;

    while(1)
    {
		app_iwt_clr();			 //清除中断等待

        app_background_evt_process();
		

        #if POWER_SAVING_ENABLE
        if(app_stop_wait_flag == 0)
        {
            __WAIT();//CPU停止工作，外设正常可中断唤醒
        }
        #endif


    }
    return 0;
}
